package com.hl.sfzy.controller.content;


import com.hl.sfzy.entity.content.ArticleType;
import com.hl.sfzy.service.content.ArticleTypeService;
import com.hl.sfzy.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Optional;

@RestController
@RequestMapping("/articleType")
public class ArticleTypeController {

    @Autowired
    private ArticleTypeService articleTypeService;


    @GetMapping("/getAll")
    public R<List<ArticleType>> getAll(){
        List<ArticleType> all = articleTypeService.getAll();
        return Optional.ofNullable(all).map(R::success).orElseGet(() -> R.failure("获取失败"));
    }
}
